<style type="text/css">
    .bg {
        background: #eee;
        padding-top: 48px;
        padding-bottom: 10px;
    }
    .daixao_intro{
        font-size: 12.8px;
        color: #666;
        line-height: 28px;
        background:#fff;
        margin: 6px 0;
        padding: 10px 20px;
    }
    .red{
        color: red;
    }
    .daixao_intro a{
        color: blue;
    }
    .daixiao_list li{
        background: #fff;
        padding: 0 14px;
    }
    .daixiao_prod img{
        width: 48px;
        height: 48px;
        margin-right: 8px;
    }
    .daixao_title{
        height: 34px;
        line-height: 34px;
        font-size: 12.8px;
        color: #999;
    }
    .daixiao_status{
        color: red;
    }
    .daixiao_prod{
        padding: 8px 0;
        border-top: 1px solid #eeeeee;
        border-bottom: 1px solid #eeeeee;
    }
    .daixiao_count{
        text-align: right;
        font-size: 13px;
        color: #999;
        height: 34px;
        line-height: 34px;
    }
    .daixiao_list li+li{
        margin-top: 6px;
    }
    .daixiao_prod span{
        color: #999;
    }
    .order_tabs{
        background: #fff;
        height: 42px;
        line-height: 42px;
        border-top: 1px solid #eee;
        margin-bottom: 6px;
    }
    .order_tabs a{
        width: 100%;
        text-align: center;
        font-size: 12.8px;
    }
    .order_tabs a.active{
        border-bottom: 2px solid red;
    }
    .order_panel{
        padding: 10px 40px;
        border-top: 1px solid #f1f1f1;
    }
    .order_panel a{
        float: left;
        width: calc((100% - 40px) / 2);
        height: 32px;
        line-height: 32px;
        text-align: center;
        font-size: 12.8px;
        color: #fff;
        background: #999;
        border-radius: 4px;
    }
    .order_panel a+a{
        margin-left: 40px;
        background: #f25353;
    }
    .positioon_list li{
        background: #fff;
        margin-bottom: 10px;
        border-top: 1px solid #d2d2d2;
        border-bottom: 1px solid #d2d2d2;
    }
    .positioon_list div{
        width: 100%;
        text-align: center;
        font-size: 12.8px;
        color: #666;
        line-height: 34px;
    }
    .red{
        color: red;
    }
    .green{
        color: green;
    }
    .up_label_btn{
        color: red;
        background: red;
        border-radius: 3px;
        padding: 2px 4px;
        color: #fff;
    }
    .down_label_btn{
        background: green;
        border-radius: 3px;
        padding: 2px 4px;
        color: #fff;
    }
    .positioon_detail li{
        background: #fff;
        margin-bottom: 10px;
        border-top: 1px solid #d2d2d2;
        border-bottom: 1px solid #d2d2d2;
    }
    .positioon_detail li>div{
        width: 50%;
    }
    .positioon_detail li>div>p{
        float: left;
        width: 50%;
        text-align: center;
        line-height: 32px;
    }
    .p_key{
        color: #999;
    }
    .p_value{
        color: #333;
    }
    .down_count p{
        float: left;
        width: 50%;
        text-align: center;
        color: red;
        line-height: 64px;
    }
    .down_count_press{
        background: #ebebeb;
        height: 10px;
        border-radius: 5px;
        overflow: hidden;
        margin-top: 26px;
        position: relative;
    }
    .down_count_press span{
        position: absolute;
        left: 0;
        width: 46%;
        top: 0;
        height: 10px;
        background: #d20102;
    }

    .game_mask{
        position: fixed;
        width: 100%;
        height: 100vh;
        background: rgba(0,0,0,.4);
        padding: 100px 24px 0 24px;
        left: 0;
        top: 0;
        z-index: 999999;
        display: none;
    }
    .game_mask_con{
        background: #fff;
        border-radius: 8px;
        overflow: hidden;
    }
    .game_mask_title{
        height: 48px;
        line-height: 48px;
        text-align: center;
        font-size: 14.4px;
        background: #eee;
        color: #333;
    }
    .game_order_params{
        padding: 10px 12px;
    }
    .game_order_params p{
        float: left;
        width: 50%;
        font-size: 12.8px;
        color: #333;
        height: 32px;
        line-height: 32px;
    }
    .order_btns{
        padding: 16px 24px;
    }
    .order_btns a{
        height: 40px;
        line-height: 40px;
        background: #eeeeee;
        width: 40%;
        text-align: center;
        font-size: 12.8px;
        border-radius: 6px;
        margin-left: 30%;
    }
    .order_btns a+a{
        background: #cc3333;
        color: #fff;
    }
</style>



<div class="pro_header">
    <a href="javascript:history.go(-1)" class="return_btn"></a>
    <?= $this->title ?>
    <a href="<?= url(['site/index']) ?>" class="to_home_btn"></a>
</div>


<p class="order_tabs flex-nowrap">
    <a href="<?= url(['site/index']) ?>">继续下单</a>
    <a <?php if($order_state == 1): ?> class="active"<?php endif ?> href="<?= url(['site/gamePosition', 'order_state' => 1]) ?>">持仓明细</a>
    <a <?php if($order_state == 2): ?> class="active"<?php endif ?> href="<?= url(['site/gamePosition', 'order_state' => 2]) ?>">交易历史</a>
</p>
<!-- 持仓明细 -->
<ul class="positioon_detail" data-url="<?= url(['order/positon', 'order_state' => 1]) ?>" data-count="<?= $pageCount ?>" data-page="1">
    <?= $this->render('_positionList', compact('data')) ?>
</ul>



<div class="game_mask">
    <div class="game_mask_con">
        <p class="game_mask_title">订单到期</p>
        <div class="game_order_params clear_fl">
            <p>周期: <span>30s</span></p>
            <p>收益比率: <span>85%</span></p>
            <p>交易品种: <span>BTB玉</span></p>
            <p>委托方向: <span>涨</span></p>
            <p>执行价格: <span>23588.22</span></p>
            <p>到期价格: <span>23588.22</span></p>
            <p>投资积分: <span>3</span></p>
            <p>实际: <span class="green">-100</span></p>
        </div>
        <p class="clear_fl order_btns">
            <a href="" class="lf cancel_btn">确定</a>
        </p>
    </div>
</div>

<div class="row pageContent" style="text-align: center;margin-bottom: 20px; <?php if($pageCount <= 1) : ?>display:none<?php endif ?>">
    <a style="color: red;margin-top: 10px;" type="button" value="加载更多" id="loadMore" data-url="<?= url(['order/positon']) ?>" data-count="<?= $pageCount ?>" data-page="1">加载更多</a>
</div>


<script type="text/javascript">
    $(".cancel_btn").click(function(e){
        e.preventDefault();
        $(this).parents(".game_mask").hide();
    });


    var timer = setInterval(function(){
        updateOrder();
    }, 1000);

    // 倒计时
    function updateOrder(){
        $.get('/price.json?' + Math.random(), function(newData) {
                $('.positioon_detail li').each(function(){
                    if ($(this).data('state') != 1) {
                        return false;
                    }

                    var lastPrice = $(this).data('price'),
                        name = $(this).data('name'),
                        $this = $(this).find('.profitPrice'),
                        rise = $this.data('rise');
                        price = parseFloat(newData[name]);
                        ltPrice = parseFloat($(this).find('.curPrice').html());
                    //数字实时跳动 
                    if (price > ltPrice) {
                        $(this).find('.curArrow').css('color', 'red');
                    } else if (price < ltPrice) {
                        $(this).find('.curArrow').css('color', 'green');
                    }
                    $(this).find('.curPrice').html(price);
                    //波动盈亏
                    var obj = $(this).find('.profitLoss'),
                        fee = obj.data('fee'),
                        oprofit = obj.data('oprofit'),
                        deposit = obj.data('deposit');
                    if ((price > lastPrice && rise == 1) || (price < lastPrice && rise == 2)) {
                        var profit = parseFloat(deposit - oprofit);
                        obj.find('.profit_con').css('color', 'red');
                        obj.find('.profit_con').html("赚<i class='font_16' style='margin-left:4px'>"+(profit).toFixed(2)+"</i>");
                    } else if ((price < lastPrice && rise == 1) || (price > lastPrice && rise == 2)) {
                        var money = parseFloat(deposit);
                        obj.find('.profit_con').css('color', 'green');
                        obj.find('.profit_con').html("亏<i class='font_16' style='margin-left:4px'>"+money+"</i>");
                    } else {
                        obj.find('.profit_con').css('color', 'red');
                        obj.find('.profit_con').html("平<i class='font_16' style='margin-left:4px'>0</i>");
                    }


                    var totalTime = $(this).attr("data-total-time");
                    var time = $(this).attr("data-time");
                    time --;
                    $(this).attr("data-time", time);

                    if( time < 0 ){
                        $(this).remove();
                    }
                    var persent = parseInt(time / totalTime * 100);
                    $(this).find(".persent").html(persent.toFixed(2) + "%");
                    $(this).find(".down_count_press span").css("width", persent.toFixed(2) + "%");
                    $(this).find(".time_count").html( time + "s" );

                });
            }, 'json');
    }


    //加载页面
        $("#loadMore").click(function() {
            var $this = $(this),
                page = parseInt($this.data('page')) + 1;
            $.get('', {
                p: page
            }, function(msg) {
                $(".positioon_detail").append(msg.info);
                $this.data('page', page);
                if (page >= parseInt($this.data('count'))) {
                    $this.hide();
                }
            });
            return false;
        });

</script>






